/*
 * Copyright (c) 2017. danlu.com Co.Ltd. All rights reserved.
 */

package cn.com.dhc.danlu.activity.delivery.order.view;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import cn.com.dhc.danlu.R;
import cn.com.dhc.danlu.widget.base.BaseFullScreenPopupView;

/**
 * author: wuhaiyang(<a href="mailto:wuhaiyang@danlu.com">wuhaiyang@danlu.com</a>)<br/>
 * version: 1.0.0<br/>
 * since: 2017-03-07 上午9:34<br/>
 *
 * <p>
 * 已取消订单 ： 原因显示pop
 * </p>
 */
public class FullScreenReasonPopupView extends BaseFullScreenPopupView {
    private TextView tvReasonTitle;
    private TextView tvReasonDes;

    public FullScreenReasonPopupView(Context context) {
        super(context);
        init(context);
    }

    /**
     * 设置取消原因的内容
     *
     * @param cancelReason
     *         原因内容
     */
    public void setCancelReason(String cancelReason) {
        if (TextUtils.isEmpty(cancelReason)) {
            return;
        }
        String compareStr = "其他原因：";
        if (cancelReason.contains(compareStr)) {
            tvReasonTitle.setText(compareStr);
            tvReasonDes.setText(cancelReason.substring(cancelReason.indexOf("：") + 1, cancelReason.length()));
        } else {
            tvReasonDes.setText("");
            tvReasonTitle.setText(cancelReason);
        }
    }

    private void init(Context context) {
        View contentView = View.inflate(context, R.layout.popup_reason_fullscreen, null);
        setContentView(contentView);
        contentView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
        tvReasonDes = (TextView) contentView.findViewById(R.id.tv_reason_dec);
        tvReasonTitle = (TextView) contentView.findViewById(R.id.tv_reason_title);
    }
}
